package com.hmall.api.client;

import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import com.hmall.api.fallback.ItemClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

@FeignClient(value = "item-service",path = "/items", fallbackFactory = ItemClientFallbackFactory.class)
public interface ItemClient {

    @GetMapping
    public List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids);

    @PutMapping("/stock/deduct")
    public void deductStock(@RequestBody Collection<OrderDetailDTO> items);

    @GetMapping("{id}")
    public ItemDTO queryItemById(@PathVariable("id") Long id);



    @PutMapping
    public void updateItem(@RequestBody ItemDTO item);

    @PutMapping("/stock/restore")
    public void batchRestoreStock(List<OrderDetailDTO> orderDetailDTOS);

    @GetMapping("pageList")
    public List<ItemDTO> getEsList(@RequestParam("page") Integer page, @RequestParam("size") Integer size);

}
